<template>
  <div class="index">
    <el-container>
      <el-aside width="200px">
        <div class="title" v-show='!isCollapse'>嗨购后台管理系统</div>
            <el-menu
            router=true
            :collapse="isCollapse"
            background-color="#111"
            text-color="white"
            default-active="2"
            class="el-menu-vertical-demo"
        >
            <el-menu-item index="/index/home">
            <el-icon><HomeFilled /></el-icon>
            <span>首页</span>
            </el-menu-item>
             <el-sub-menu index="2">
            <template #title>
              <el-icon><VideoCameraFilled /></el-icon>
              <span>轮播图管理</span>
            </template>
            <el-menu-item index="/index/swiper">
              <el-icon><icon-menu /></el-icon>
              <span>轮播图列表</span>
            </el-menu-item>
          </el-sub-menu>
           <el-sub-menu index="3">
            <template #title>
              <el-icon><Avatar /></el-icon>
              <span>账号管理</span>
            </template>
            <el-menu-item index="/index/admin">
              <el-icon><icon-menu /></el-icon>
              <span>管理员列表</span>
            </el-menu-item>
          </el-sub-menu>
            <el-sub-menu index="4">
                    <template #title>
                    <el-icon><ScaleToOriginal /></el-icon>
                    <span>产品管理</span>
                    </template>
                    <el-menu-item index="/index/cplb">
                    <el-icon><icon-menu /></el-icon>
                    <span>产品列表</span>
                    </el-menu-item>
                     <el-menu-item index="/index/mslb">
                    <el-icon><icon-menu /></el-icon>
                    <span>秒杀列表</span>
                    </el-menu-item>
                     <el-menu-item index="/index/tjlb">
                    <el-icon><icon-menu /></el-icon>
                    <span>推荐列表</span>
                    </el-menu-item>
                     <el-menu-item index="/index/sxlb">
                    <el-icon><icon-menu /></el-icon>
                    <span>筛选列表</span>
                    </el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="5">
            <template #title>
              <el-icon><View /></el-icon>
              <span>数据可视化</span>
            </template>
            <el-menu-item index="/index/echarts">
              <el-icon><icon-menu /></el-icon>
              <span>echarts使用</span>
            </el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="6">
            <template #title>
              <el-icon><KnifeFork /></el-icon>
              <span>编辑器</span>
            </template>
            <el-menu-item index="/index/bianjiqi">
              <el-icon><icon-menu /></el-icon>
              <span>编辑器使用</span>
            </el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="7">
            <template #title>
             <el-icon><DocumentDelete /></el-icon>
              <span>excel管理</span>
            </template>
            <el-menu-item index="/index/excel">
              <el-icon><icon-menu /></el-icon>
              <span>excel使用</span>
            </el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="8">
            <template #title>
              <el-icon><MapLocation /></el-icon>
              <span>地图管理</span>
            </template>
            <el-menu-item index="/index/baidumap">
              <el-icon><icon-menu /></el-icon>
              <span>百度地图</span>
            </el-menu-item>
          </el-sub-menu>
           
        </el-menu>
      </el-aside>
      <el-container>
        <el-header class="header">
            <div class="headerleft">
                <el-icon @click="zhedie" v-if="!isCollapse"><Fold /></el-icon>
                <el-icon @click="zhedie" v-else><Expand /></el-icon>
            </div>
            <div class="headerright">
                <span>欢迎: {{loginStore.loginData.adminname}} </span>
                 <el-dropdown @command="handleCommand">
               <el-icon class="person"><UserFilled /></el-icon>
                <template #dropdown>
                <el-dropdown-menu>
                    <el-dropdown-item command="shezhi">设置</el-dropdown-item>
                    <el-dropdown-item command="tuichu">退出</el-dropdown-item>
                </el-dropdown-menu>
                </template>
            </el-dropdown>
            </div>
        </el-header>
        <el-main>
             <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import{ref} from 'vue'
import { useRouter } from "vue-router";
import { useLoginStore } from '@/stores/login'

import { ElNotification } from 'element-plus'
import 'element-plus/es/components/notification/style/css'

var loginStore = useLoginStore()
var $router = useRouter();
var isCollapse=ref(false)

var handleCommand = (a) => {
  if (a == "tuichu") {
    loginStore.removeLoginData()
     ElNotification({
          title:'退出通知',
          message:"退出成功",
          type:'success',
          duration: 1000
        })
    $router.push("/login");
  }
};
var zhedie=()=>{
    isCollapse.value=!isCollapse.value
}
</script>

<style scoped lang='scss'>
.index{
    .title{
        color: #fff;
        font-size: 22px;
        font-weight: 700;
        margin: 20px 0;
        text-align: center;
    }
    .el-menu{
      border: 0;
    }
    .el-aside {
    background-color: #111;
    width: auto !important;
  }
  .header{
     display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #111;
    color:white;
    .person{
        font-size: 16px;
        color:white;
    }
  }
  
}
</style>